package genetic.operators;

import genetic.interfaces.Individual;
import genetic.interfaces.Mutation;

public class MutationSinglePoint<I extends Individual<Integer,?>> implements Mutation<I>{
	
	private int maxValue;
	
	public MutationSinglePoint(int maxValue) {
		this.maxValue = maxValue;
	}
	//Randomiza o gene a ser inserido
	public int RandGene(int suplimit, int inflimit){
		Integer gene;

		gene = (int) (inflimit + Math.random()*suplimit);
		return gene;
	}

	public void mutation(I individual) {
		int index;

//		System.out.println("Mutation SPoint");
		
		index = (int) (Math.random() * individual.getNumberOfGenes());
		
		individual.setGene(index, RandGene(maxValue, 0));
	}

}